package com.caocaog.market.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.caocaog.market.entity.OrderLine;
import com.caocaog.market.mapper.OrderLineMapper;
import com.caocaog.market.service.IOrderLineService;
import org.jeecg.common.exception.JeecgBootException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

/**
 * 商品订单行表
 *
 * @author jeecg-boot
 * @date 2021-11-29
 */
@Service
@Transactional(rollbackFor = JeecgBootException.class)
public class OrderLineServiceImpl extends ServiceImpl<OrderLineMapper, OrderLine> implements IOrderLineService {

    @Override
    public List<OrderLine> getByOrderId(String orderId) {
        return baseMapper.getByOrderId(orderId);
    }


    @Override
    public LinkedList<HashMap<String, Object>> getSales(String shopId, Integer type) {
        return super.baseMapper.getSales(shopId, type);
    }

    @Override
    public Map<String, LinkedList<HashMap<String, Object>>> getOrderAmount(String shopId) {
        return new HashMap<String, LinkedList<HashMap<String, Object>>>(3) {{
            put("all", baseMapper.getOrderAmount(shopId, null));
            put("takeout", baseMapper.getOrderAmount(shopId, 1));
            put("pickUp", baseMapper.getOrderAmount(shopId, 2));
        }};
    }

    @Override
    public LinkedList<HashMap<String, Object>> getSumOfBusiness(String shopId) {
        return super.baseMapper.getSumOfBusiness(shopId);
    }


}
